<?php
require('config.php');
		$n=$_REQUEST['n'];
		$sql="select * from `".$oto."_goods_cats` where catFlag=1";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$list[]=$row;//将取得的所有数据赋值给person_info数组
		}
		$yiji_num=0;
		for($i=0;$i<count($list);$i++)
		{
			if($list[$i]['parentId']==0 && $list[$i]['isFixed']==$n)
			{
				$data[$yiji_num]=$list[$i];
				$erji_num=0;
				for($j=0;$j<count($list);$j++)
				{
					if($list[$i]['catId']==$list[$j]['parentId'])
					{
						$data[$yiji_num]['list'][$erji_num]=$list[$j];
						$sanji_num=0;
						for($k=0;$k<count($list);$k++)
						{
							if($list[$j]['catId']==$list[$k]['parentId'])
							{
								$data[$yiji_num]['list'][$erji_num]['list'][$sanji_num]=$list[$k];
								$sanji_num++;
							}
						}
						if($sanji_num==0) $data[$yiji_num]['list'][$erji_num]['list']=[];
						$erji_num++;
					}
				}
				if($erji_num==0) $data[$yiji_num]['list']=[];
				$yiji_num++;
			}
		}
		//print_r($data);
		echo json_encode($data);
?>